//
//  GTRefreshView.swift
//  swiftWEIbo
//
//  Created by mac－gt on 15/11/30.
//  Copyright © 2015年 mac－gt. All rights reserved.
//

import UIKit

class GTRefreshView: UIView {

    @IBOutlet weak var loadView: UIImageView!
    @IBOutlet weak var tipView: UIView!
    @IBOutlet weak var srowView: UIImageView!
    class func refreshView()->GTRefreshView{
        return NSBundle.mainBundle().loadNibNamed("GTRefreshView", owner: nil, options: nil).last as! GTRefreshView
    }
    func srowViewAnimation(isUp:Bool){
        UIView.animateWithDuration(0.25, animations: { () -> Void in
            
            self.srowView.transform = isUp ? CGAffineTransformMakeRotation(CGFloat(M_PI-0.01)):CGAffineTransformIdentity
            }) { (_) -> Void in
                
        }
    }
    func loadViewAnimation(){
        if let _ = self.loadView.layer.animationForKey("anim"){
            return
        }
        tipView.hidden=true
        let anim=CABasicAnimation(keyPath: "transform.rotation")
        anim.toValue=2 * M_PI
        anim.repeatCount=MAXFLOAT
        anim.repeatDuration=10
        self.loadView.layer.addAnimation(anim, forKey: "anim")
    }
    func stopLoad(){
        tipView.hidden=false
        self.loadView.layer.removeAllAnimations()
    }
}
